<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CrateShopOrderTable extends Migration
{

    public function up()
    {
        //订单表
        Schema::create('shop_order', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->comment('用户ID');
            $table->string('pay_id',50)->default('0')->comment('支付日志ID');
            $table->string('order_express_id',50)->default('0')->comment('配送ID');

            $table->string('out_trade_no', 23)->comment('生成订单号');
            $table->string('product_title')->comment('产品名称');
            $table->unsignedDecimal('discount_point', 10, 2)->default(0)->comment('商城抵扣');
            $table->unsignedDecimal('discount_coupon', 10, 2)->default(0)->comment('优惠券抵扣');
            $table->string('coupon_id',50)->default('0')->comment('优惠券ID');
            $table->unsignedDecimal('freight', 10, 2)->comment('运费');
            $table->unsignedDecimal('total_price', 10, 2)->comment('订单金额');
            $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('实收金额');
            $table->boolean('pay_status')->default(false)->comment('支付状态 0=未支付 1=已支付');
            $table->boolean('deleted')->default(false)->comment('删除 0=未删除,1=删除');
            $table->boolean('user_deleted')->default(false)->comment('用户删除 0未删除 , 1=已删除');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('shop_order');
    }
}
